<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column type="index" width="50">
      </el-table-column>
      <el-table-column prop="name" label="名称" width="180">
      </el-table-column>
      <el-table-column prop="url" label="地址">
      </el-table-column>
      <el-table-column prop="type" label="类型">
      </el-table-column>
      <el-table-column prop="interfaceId" label="接口ID">
      </el-table-column>
      <el-table-column prop="dataCode" label="数据代码">
      </el-table-column>
      <el-table-column prop="serviceNodeId" label="服务节点ID">
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
      :current-page.sync="currentPage1" :page-size="100" background layout="prev, pager, next" :total="1000">
    </el-pagination>
  </div>
</template>

<script>
import { getSkyEnginePage } from '@/api/SkyEngine'
export default {
  name: 'SkyList',
  data() {
    return {
      tableData: [],
      currentPage1: 5,
    }
  },
  mounted() {
    this.getSkyPage();
  },
  methods: {
    /**
     * 获取天擎分页
     */
    getSkyPage() {
      getSkyEnginePage().then(res => {
        this.tableData = res.responseData.data.records;
      }).catch(res => {
          console.log(res);
          // 可以在这里处理错误，比如显示错误消息
        })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleClick(row) {
      this.$router.push({ path: 'SkyEngineDetails', query: { id: row.id } })
    }
  }
}
</script>

<style scoped></style>